package zcw.com.lib_leet_code;

/**
 * Created by 朱城委 on 2021/7/13.<br><br>
 *
 * 2的幂
 */
public class Topic231 {
    public static void main(String[] args) {
       Topic231 instance = new Topic231();

        System.out.println(instance.isPowerOfTwo(2));
        System.out.println(instance.isPowerOfTwo(16));
        System.out.println(instance.isPowerOfTwo(3));
        System.out.println(instance.isPowerOfTwo(4));
        System.out.println(instance.isPowerOfTwo(5));
    }

    public boolean isPowerOfTwo(int n) {
        return (n > 0) && (n & (n - 1)) == 0;
    }
}
